Conventionally, a graphics surface is divided into smaller primitives (e.g., triangles). The primitives are rasterized and other operations are performed to generate pixels for visible portions of primitives. Individual pixels are also shaded to generate the pixel color, generate transparencies, and perform other effects.
A graphics pipeline typically includes a pixel shader to shade pixels. A pixel shader converts a set of texture coordinates into a color using a shader program. Textures conventionally have horizontal and vertical texture coordinates mapped to an (s, t) space using a plane equation. The pixel shading may, for example, be performed using parallel processing units.
Note that in a conventional pixel shading paradigm the shading of primitives is performed largely independent of one another. This permits the processing work to be distributed amongst parallel shading elements until all of the primitives of a frame are shaded. Thus, in a conventional shading paradigm a first primitive is shaded, then another, and so on until all of the primitives of the frame are shaded. One aspect of this shading paradigm is that typically intermediate calculations used to shade pixels of individual primitives are not retained after a particular primitive is shaded.
In addition to performing texture operations to calculate a pixel color, a pixel shader may also perform filtering operations that require calculating an estimate of texture derivatives with respect to neighboring pixels. The derivatives are estimated based on differences in texture values with respect to a neighboring pixel. The texture values may, for example, be calculated at pixel centers in a pixel “footprint” about the pixel being shaded. As one example, the footprint may be a group of four pixels (a “quad”) including the pixel being shaded. Thus, a common algorithm for shading an individual pixel is to select a footprint of pixels about the pixel, determine the texture value at pixel centers in the footprint about the pixel being shaded using an appropriate plane equation, and utilize difference equations to estimate texture derivatives for filtering the pixel being shaded.
A problem with conventional pixel shaders is that the efficiency of the shading process tends to decrease as the triangle size shrinks. This decrease in efficiency with decreasing triangle size is caused by the need to calculate neighboring exterior pixels outside of a triangle solely for the purpose of estimating texture derivatives for interior edge pixels of the triangle. As previously described, once a particular triangle is shaded typically the intermediate calculations used to shade the triangle are not retained. As a result, triangles with a high perimeter-to-area ratio will require a significant number of exterior pixels per interior pixel to be calculated solely for estimating texture derivatives. This is a particular concern when the derivatives of the texture coordinates are the result of a long chain of calculations such that the entire shader program must be executed.
FIG. 1 illustrates a primitive 100 which is to be shaded. An individual pixel 112 has a pixel center within primitive 100 proximate edge 105 such that pixel 112 will be shaded. In order to calculate texture derivatives for pixel 112, texture values for other pixels 114, 116, and 118 outside of primitive 100 must be calculated as part of a group derivative footprint 110, such as a quad of four pixels. Thus, for a pixel 112 to be shaded, the other pixels 114, 116, and 118 within the group footprint 110 must also be rendered to generate derivative information. For a comparatively large primitive 100 this may not be a concern since the perimeter-to-area ratio is low. However, referring to FIG. 2, for a comparatively small primitive 200, the perimeter-to-area ratio increases. As a result, a large percentage of the pixels will be edge pixels, such as a pixel 212 near edge 205, increasing the fraction of exterior pixels that must be calculated for the sole purpose of generating derivative information. For example, exterior pixels 214, 216, and 218 of quad 210 must be rendered to generate texture derivatives for pixel 212. It can be understood from comparing FIGS. 1 and 2 that as the triangle size shrinks the computational resources required to calculate texture derivatives increases.
There is an increasing interest in performing graphics processing of complex surfaces. Complex surfaces are best processed by dividing the surface into comparatively small primitives (triangles). However, as previously described, this may result in a large increase in the computational resources that must be devoted to calculating texture derivatives.
In light of the above-described problems, the apparatus and system of the present invention was developed.